package com.yjt.common.entity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 分页查询公共条件实体类
 */
@Data
public abstract class CommonParam implements Serializable {

    /**
     * @Fields serialVersionUID
     */
    private static final long serialVersionUID = 1L;

    /**
     * 条数
     */
    @ApiModelProperty(value = "条数", example = "10")
    private Long pageSize = 20L;

    /**
     * 当前页
     */
    @ApiModelProperty(value = "当前页", example = "1")
    private Long pageNumber = 1L;

    /**
     * 转换为page对象
     *
     * @param <T>
     * @return
     */
    public <T> Page toPage() {
        Page<T> page = new Page<>();
        page.setSize(this.pageSize);
        page.setCurrent(this.pageNumber);
        return page;
    }
}
